package com.inspur.security.cbb3.kms.keyusage.dataorders.repository;

import com.inspur.security.cbb3.kms.keyusage.dataorders.po.DataOrdersBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface DataOrdersRepository extends JpaRepository<DataOrdersBean, String>, JpaSpecificationExecutor<DataOrdersBean> {

    /**
     * 更新订单状态
     * @param status 订单状态
     * @param uuid 订单uuid
     */
    @Transactional
    @Modifying
    @Query(value = "update DataOrdersBean db set db.status=?1 where db.uuid=?2")
    void updataStatus(String status, String uuid);

    /**
     * 更新订单错误原因
     * @param errorReason 错误原因
     * @param uuid 订单uuid
     */
    @Transactional
    @Modifying
    @Query(value = "update DataOrdersBean db set db.errorReason=?1 where db.uuid=?2")
    void updataErrorReason(String errorReason, String uuid);

}
